package com.atguigu.staservice.schedule;

import com.atguigu.staservice.service.StatisticsDailyService;
import com.atguigu.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @Author: LDeng
 * @Date: 2020-09-24 16:38
 */

@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

//    @Scheduled(cron="0/5 * * * * ?")
//    public void task1(){
//        System.out.println("=======================>task1 执行");
//    }

    /**
     * 每天定时统计
     */
    @Scheduled(cron="0/60 * * * * ?")
    public void registerCount(){
        String day= DateUtil.formatDate(new Date());
        statisticsDailyService.registerCount(day);
        System.out.println("=======================>统计注册人数>>>"+day+"<<<执行");
    }


}
